import 'package:json_annotation/json_annotation.dart';
part 'home_list_data.g.dart';

@JsonSerializable()
class HomeData {
  @JsonKey(name: 'data')
  HomeListData? data;
  @JsonKey(name: 'errorCode')
  int? errorCode;
  @JsonKey(name: 'errorMsg')
  String? errorMsg;

  HomeData({this.data, this.errorCode, this.errorMsg});

  factory HomeData.fromJson(Map<String, dynamic> json) =>
      _$HomeDataFromJson(json);

  static List<HomeData> fromList(List<Map<String, dynamic>> list) {
    return list.map(HomeData.fromJson).toList();
  }

  Map<String, dynamic> toJson() => _$HomeDataToJson(this);
}

@JsonSerializable()
class HomeListData {
  @JsonKey(name: 'curPage')
  int? curPage;
  @JsonKey(name: 'datas')
  List<HomeListItemData>? datas;
  @JsonKey(name: 'offset')
  int? offset;
  @JsonKey(name: 'over')
  bool? over;
  @JsonKey(name: 'pageCount')
  int? pageCount;
  @JsonKey(name: 'size')
  int? size;
  @JsonKey(name: 'total')
  int? total;

  HomeListData({
    this.curPage,
    this.datas,
    this.offset,
    this.over,
    this.pageCount,
    this.size,
    this.total,
  });

  factory HomeListData.fromJson(Map<String, dynamic> json) =>
      _$HomeListDataFromJson(json);

  static List<HomeListData> fromList(List<Map<String, dynamic>> list) {
    return list.map(HomeListData.fromJson).toList();
  }

  Map<String, dynamic> toJson() => _$HomeListDataToJson(this);
}

@JsonSerializable()
class HomeListItemData {
  @JsonKey(name: 'adminAdd')
  bool? adminAdd;
  @JsonKey(name: 'apkLink')
  String? apkLink;
  @JsonKey(name: 'audit')
  int? audit;
  @JsonKey(name: 'author')
  String? author;
  @JsonKey(name: 'canEdit')
  bool? canEdit;
  @JsonKey(name: 'chapterId')
  int? chapterId;
  @JsonKey(name: 'chapterName')
  String? chapterName;
  @JsonKey(name: 'collect')
  bool? collect;
  @JsonKey(name: 'courseId')
  int? courseId;
  @JsonKey(name: 'desc')
  String? desc;
  @JsonKey(name: 'descMd')
  String? descMd;
  @JsonKey(name: 'envelopePic')
  String? envelopePic;
  @JsonKey(name: 'fresh')
  bool? fresh;
  @JsonKey(name: 'host')
  String? host;
  @JsonKey(name: 'id')
  int? id;
  @JsonKey(name: 'isAdminAdd')
  bool? isAdminAdd;
  @JsonKey(name: 'link')
  String? link;
  @JsonKey(name: 'niceDate')
  String? niceDate;
  @JsonKey(name: 'niceShareDate')
  String? niceShareDate;
  @JsonKey(name: 'origin')
  String? origin;
  @JsonKey(name: 'prefix')
  String? prefix;
  @JsonKey(name: 'projectLink')
  String? projectLink;
  @JsonKey(name: 'publishTime')
  int? publishTime;
  @JsonKey(name: 'realSuperChapterId')
  int? realSuperChapterId;
  @JsonKey(name: 'selfVisible')
  int? selfVisible;
  @JsonKey(name: 'shareDate')
  int? shareDate;
  @JsonKey(name: 'shareUser')
  String? shareUser;
  @JsonKey(name: 'superChapterId')
  int? superChapterId;
  @JsonKey(name: 'superChapterName')
  String? superChapterName;
  @JsonKey(name: 'tags')
  List<dynamic>? tags;
  @JsonKey(name: 'title')
  String? title;
  @JsonKey(name: 'type')
  int? type;
  @JsonKey(name: 'userId')
  int? userId;
  @JsonKey(name: 'visible')
  int? visible;
  @JsonKey(name: 'zan')
  int? zan;

  HomeListItemData({
    this.adminAdd,
    this.apkLink,
    this.audit,
    this.author,
    this.canEdit,
    this.chapterId,
    this.chapterName,
    this.collect,
    this.courseId,
    this.desc,
    this.descMd,
    this.envelopePic,
    this.fresh,
    this.host,
    this.id,
    this.isAdminAdd,
    this.link,
    this.niceDate,
    this.niceShareDate,
    this.origin,
    this.prefix,
    this.projectLink,
    this.publishTime,
    this.realSuperChapterId,
    this.selfVisible,
    this.shareDate,
    this.shareUser,
    this.superChapterId,
    this.superChapterName,
    this.tags,
    this.title,
    this.type,
    this.userId,
    this.visible,
    this.zan,
  });

  factory HomeListItemData.fromJson(Map<String, dynamic> json) =>
      _$HomeListItemDataFromJson(json);

  static List<HomeListItemData> fromList(List<Map<String, dynamic>> list) {
    return list.map(HomeListItemData.fromJson).toList();
  }

  Map<String, dynamic> toJson() => _$HomeListItemDataToJson(this);
}
